<?php

$opml_array = array(
	'head' => array(
		'title' => FreshRSS_Context::$system_conf->title,
		'dateCreated' => date('D, d M Y H:i:s')
	),
	'body' => array()
);

foreach ($this->categories as $key => $cat) {
	$opml_array['body'][$key] = array(
		'text' => $cat['name'],
		'@outlines' => array()
	);

	foreach ($cat['feeds'] as $feed) {
		$opml_array['body'][$key]['@outlines'][] = array(
			'text' => htmlspecialchars_decode($feed->name(), ENT_QUOTES),
			'type' => 'rss',
			'xmlUrl' => htmlspecialchars_decode($feed->url(), ENT_QUOTES),
			'htmlUrl' => htmlspecialchars_decode($feed->website(), ENT_QUOTES),
			'description' => htmlspecialchars_decode($feed->description(), ENT_QUOTES),
		);
	}
}

echo libopml_render($opml_array);
